package com.feng.gameproj;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.view.View;

public class BitmapView extends View implements Runnable 
{
	private Resources res = null;
	
	private Bitmap pict_1 = null;
	private Bitmap pict_2 = null;
	
	private Paint paint = null;

	public BitmapView(Context context) 
	{
		super(context);
		
		this.res = getResources ();
		this.paint = new Paint ();
		
		BitmapDrawable tmp = (BitmapDrawable)this.res.getDrawable(R.drawable.drop);
		this.pict_1 = tmp.getBitmap();
		tmp = (BitmapDrawable)this.res.getDrawable(R.drawable.black_drop);
		this.pict_2 = tmp.getBitmap();
		
		new Thread (this).start();
	}

	@Override
	protected void onDraw(Canvas canvas) 
	{
		super.onDraw(canvas);
		
		canvas.drawBitmap(this.pict_1, 0, 0, paint);
		canvas.drawBitmap(this.pict_2, 0, this.pict_1.getHeight()+10, paint);
	}

	@Override
	public void run() 
	{
		while (! Thread.currentThread().isInterrupted())
		{
			try 
			{
				Thread.sleep(500);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Thread.currentThread().interrupt();
			}
			postInvalidate ();
		}
	}

}
